package com.atguigu.bigdata.spark.core.rdd.operator.transform;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

public class Spark11_RDD_Operator_Transform_JAVA {
    public static void main(String[] args) {
        //repartition算子
        // 底层代码调用coalesce算子 扩大分区,并且shuffle
        SparkConf conf = new SparkConf().setMaster("local[*]").setAppName("sparkCore");
        JavaSparkContext sc = new JavaSparkContext(conf);
        List<Integer> list = Arrays.asList(1,2,3,4,5,6);
        JavaRDD<Integer> rdd = sc.parallelize(list,2);
        JavaRDD<Integer> repartion = rdd.repartition(3);
        repartion.saveAsTextFile("output");
        sc.stop();
    }
}
